package com.report.controller;


import com.report.dto.Response;
import com.report.service.BalanceService;
import com.report.vo.BalanceReq;
import com.report.vo.BalanceSyncReq;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.ParseException;

/**
 * 凭证
 */
@RestController
public class BalanceController {

    @Resource
    private BalanceService balanceService;

    /**
     * 同步数据
     *
     * @param balanceSyncReq
     */
    @PostMapping("/syncData")
    public void syncData(@RequestBody BalanceSyncReq balanceSyncReq) {

        balanceService.syncData(balanceSyncReq);
    }

    /**
     * 获取科目余额列表
     */
    @PostMapping("/getSubjectBalances")
    public Response getSubjectBalances(@RequestBody BalanceReq balanceReq) {
        Response response = new Response();
        response.setStatus("success");
        response.setMessage("success");
        response.setData(balanceService.getSubjectBalances(balanceReq));
        return response;
    }

    /**
     * 获取科目明细(科目编号)
     */
    @PostMapping("/getSubjectBalanceDetails")
    public Response getSubjectBalanceDetails(@RequestBody BalanceReq balanceReq) {
        Response response = new Response();
        response.setStatus("success");
        response.setMessage("success");
        response.setData(balanceService.getSubjectBalanceDetails(balanceReq));
        return response;
    }


    /**
     * 获取辅助明细(科目编号)
     */

    @PostMapping("/getAccountingProjectDetails")
    public Response getAccountingProjectDetails(@RequestBody BalanceReq balanceReq) {
        Response response = new Response();
        response.setStatus("success");
        response.setMessage("success");
        response.setData(balanceService.getAccountingProjectDetails(balanceReq));
        return response;
    }

    /**
     * 获取凭证
     *
     * @param balanceReq
     * @return
     * @throws ParseException
     */
    @PostMapping("/getVouchers")
    public Response getVouchers(@RequestBody BalanceReq balanceReq) throws ParseException {
        Response response = new Response();
        response.setStatus("success");
        response.setMessage("success");
        response.setData(balanceService.getVouchers(balanceReq));
        return response;
    }

    //科目余额接口
    //核算项目余额表


}
